package logic

import (
	"context"
	"gozerogateway/common/errorx"

	"gozerogateway/rpc/market/internal/svc"
	"gozerogateway/rpc/market/marketclient"

	"github.com/zeromicro/go-zero/core/logx"
)

type PanelGroupDataLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewPanelGroupDataLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PanelGroupDataLogic {
	return &PanelGroupDataLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *PanelGroupDataLogic) PanelGroupData(in *marketclient.PanelGroupDataReq) (*marketclient.PanelGroupDataResp, error) {
	// todo: add your logic here and delete this line

	count1, err1 := l.svcCtx.SvcModel.Count(l.ctx)
	if err1 != nil {
		return nil, errorx.NewDefaultError("search service num error")
	}

	count2, err2 := l.svcCtx.AppModel.Count(l.ctx)
	if err2 != nil {
		return nil, errorx.NewDefaultError("search app num error")
	}
	return &marketclient.PanelGroupDataResp{
		ServiceNum:      count1,
		AppNum:          count2,
		TodayRequestNum: 0,
		CurrentQPS:      0,
	}, nil
}
